const express = require('express');
const { query } = require('../mysql/query');
const router = express.Router();

/* GET home page. */
router.get('/', function (req, res, next) {
  res.send('会议模块');
});

router.get('/getHost',async function(req,res,next){
  try {
    
  } catch (error) {
    res.send(error);
    throw (error);
  }
})
// {"hostId":"主办人员工号","joinIdArray":["参与人员工号1","参与人员工号2","参与人员工号3"...],"roomId":"会议室号","title":"会议标题","content":"会议简介","date":"会议日期","time":"会议举办时间"}
router.post('/appoint',async function(req,res,next){
  try {
    let {hostId,joinIdArray,roomId,title,content,date,time}=req.body;
  let mark = Math.floor(Math.random()*10000)+1;
  for(let i=0;i<joinIdArray.length;i++){
    // console.log(roomId+' '+hostId+' '+joinIdArray[i]+' '+title+' '+content+' '+date+' '+time+' '+ mark);
    await query(`INSERT INTO ljz_meeting_meeting_message (host_clerk_id,join_clerk_id,room_id,title,content,date,time_slot,mark) VALUES (${hostId},${joinIdArray[i]},${roomId},'${title}','${content}','${date}','${time}',${mark})`);
  }
  res.send('success');
  } catch (error) {
    res.send(error);
    throw (error);
  }
});
module.exports = router;
